﻿@model MoskieBlog.Data.Models.User

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>User</legend>

        @Html.HiddenFor(model => model.UserId)

        <div class="editor-label">
            @Html.LabelFor(model => model.UserName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserName)
            @Html.ValidationMessageFor(model => model.UserName)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>

        <div class="controls">                
            
            @foreach(MoskieBlog.Data.Models.Role role in ViewBag.Roles) {
                <label class="checkbox"> 
                    <input type="checkbox" id="optionsCheckbox" name="roleId" value="@role.RoleId" @if (Model.Roles.Any(r => r.RoleId == role.RoleId)) { <text>checked="checked"</text> }>
                    @role.RoleName
                </label>                  
            }
        </div>

    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
